package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-16 14:27
 */
public class Solution_0441 {
    /**
     * 第K行必须有K个数
     * 考虑越界问题
     *
     * @param n
     * @return
     */
    public int arrangeCoins(int n) {
        long temp = 2 * (long) n;
        System.out.println(temp);
        for (int i = 1; i <= n; i++) {
            long max = (1 + i) * (1 + i + 1);
            long min = (1 + i) * i;
            if (temp >= min && temp < max)
                return i;
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution_0441 solution_0441 = new Solution_0441();
        solution_0441.arrangeCoins(1804289383);
        System.out.println(solution_0441.arrangeCoins(1804289383));
        System.out.println(60070 * 60070);
        long a = 60070;
        System.out.println(a * a);
        long b = 60069;
        System.out.println(b * b);
        System.out.println(1804289383);
        System.out.println(b < 60070);
    }

    public int arrangeCoins1(int n) {
        return 0;
    }
}
